package com.design.迭代器模式;

import java.util.ArrayList;
import java.util.List;

public class ProdIterator extends AbstractIterator {

	private List<Object> objectList = new ArrayList<Object>();
	private int c1;
	private int c2;

	public ProdIterator(ConcreateObjectList obj) {
		this.objectList = obj.getList();
		this.c1 = 0;
		this.c2 = this.objectList.size() - 1;
	}

	@Override
	public void next() {
		if (c1 < this.objectList.size()) {
			c1++;
		}
	}

	@Override
	public void prev() {
		if (c2 > -1) {
			c2--;
		}
	}

	@Override
	public Object getPrev() {
		return this.objectList.get(c2);
	}

	@Override
	public Object getNext() {
		return this.objectList.get(c1);
	}

	@Override
	public boolean isNext() {
		return (this.c1 == this.objectList.size());
	}

	@Override
	public boolean isFirst() {
		return (this.c2 == -1);
	}

}
